<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>列表页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <!--标准mui.css-->
    <link rel="stylesheet" href="__PUBLIC__/css/mui.min.css">
    <!--App自定义的css-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/app.css" />
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <style type="text/css">
        body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=IAwxRMWcGZiNzohAyxcImHbZEGM4SXsH"></script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
    <a onclick="dump('{:U('join')}')" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <script>
        //url跳转
        function dump(url) {
            location.href=url
        }
    </script>
    <h1 class="mui-title">仓库(列表)</h1><a href="{:U('mycangku')}" class="mui-qiehuan-icon  mui-pull-right"></a>
</header>
<html>
<body>
<div id="allmap"></div>
<foreach name="data" item="vo">
    <input type="hidden" class="data" value="{$vo.Name}" url="{:U('GET_MYWH',array('id'=>$vo['StoreID']))}" Lng="{$vo.Lng}" Lat="{$vo.Lat}">
</foreach>
</body>
</html>
<!--<script type="text/javascript">
    // 百度地图API功能
    map = new BMap.Map("allmap");
    map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
    // 添加带有定位的导航控件
    var navigationControl = new BMap.NavigationControl({
        // 靠左上角位置
        anchor: BMAP_ANCHOR_TOP_LEFT,
        // LARGE类型
        type: BMAP_NAVIGATION_CONTROL_LARGE,
        // 启用显示定位
        enableGeolocation: true
    });
    map.addControl(navigationControl);
    // 添加定位控件
    var geolocationControl = new BMap.GeolocationControl();
    geolocationControl.addEventListener("locationSuccess", function(e){
        // 定位成功事件
        var address = '';
        address += e.addressComponent.province;
        address += e.addressComponent.city;
        address += e.addressComponent.district;
        address += e.addressComponent.street;
        address += e.addressComponent.streetNumber;
        //alert("当前定位地址为：" + address);
    });
    geolocationControl.addEventListener("locationError",function(e){
        // 定位失败事件
        alert(e.message);
    });
    map.addControl(geolocationControl);
</script>
<script type="text/javascript">
    /*// 百度地图API功能
    var data_info = [[116.417854,39.921988,"地址：北京市东城区王府井大街88号乐天银泰百货八层"],
        [116.406605,39.921585,"地址：北京市东城区东华门大街"],
        [116.412222,39.912345,"地址：北京市东城区正义路甲5号"]
    ];*/
    var opts = {
        width : 250,     // 信息窗口宽度
        height: 80,     // 信息窗口高度
        title : "信息窗口" , // 信息窗口标题
        enableMessage:true//设置允许信息窗发送短息
    };
    /*for(var i=0;i<data_info.length;i++){
        var marker = new BMap.Marker(new BMap.Point(data_info[i][0],data_info[i][1]));  // 创建标注
        var content = data_info[i][2];
        map.addOverlay(marker);               // 将标注添加到地图中
        addClickHandler(content,marker);
    }*/
    $(".data").each(function(){
        var marker = new BMap.Marker(new BMap.Point($(this).attr('Lng'),$(this).attr('Lat')));  // 创建标注
        var content = $(this).val()
        map.addOverlay(marker);               // 将标注添加到地图中
        addClickHandler(content,marker);
    });
    function addClickHandler(content,marker){
        marker.addEventListener("click",function(e){
            openInfo(content,e)}
        );
    }
    function openInfo(content,e){
        var p = e.target;
        var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
        var infoWindow = new BMap.InfoWindow(content,opts);  // 创建信息窗口对象
        map.openInfoWindow(infoWindow,point); //开启信息窗口
    }
</script>
<script>
    $(function() {
        $(".BMap_geolocationIcon").trigger("click");//触发button的click事件
    })
</script>-->
<script>
     opts = {

    };
     icon = new BMap.Icon('point.png', new BMap.Size(25, 25), {
    });
     map = new BMap.Map("allmap");
    var geolocation = new BMap.Geolocation();
    geolocation.getCurrentPosition(function (r) {
        if (this.getStatus() == BMAP_STATUS_SUCCESS) {
            //alert('您的位置：' + r.point.lng + ',' + r.point.lat);
            lat = r.point.lat;
            lon = r.point.lng;
            //转换为百度坐标
            var po = new BMap.Point(lon, lat);
            //生成地图
            map.centerAndZoom(po,14);
            var mkr = new BMap.Marker(new BMap.Point(lon, lat), {icon: icon});
            map.addOverlay(mkr);
            var label = new BMap.Label('这是我的位置',{offset:new BMap.Size(20,-10)});
            //marker.setLabel(label);
            //addClickHandler('这是我的位置',mkr);
            //仓库标注
            $(".data").each(function(){
                var marker = new BMap.Marker(new BMap.Point($(this).attr('Lng'),$(this).attr('Lat')));  // 创建标注
                var content = $(this).val()
                map.addOverlay(marker);               // 将标注添加到地图中
                addClickHandler('<a href="'+$(this).attr('url')+'">'+content+'</a>',marker);
                //var label = new BMap.Label(content,{offset:new BMap.Size(20,-10)});
                //marker.setLabel(label);
            });
        }
        else {
            alert('百度地图地位失败！' + this.getStatus());
        }
    }, { enableHighAccuracy: true })
    function addClickHandler(content,marker){
        marker.addEventListener("click",function(e){
            openInfo(content,e)}
        );
    }
    function openInfo(content,e){0
        var p = e.target;
        var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
        var infoWindow = new BMap.InfoWindow(content,opts);  // 创建信息窗口对象
        map.openInfoWindow(infoWindow,point); //开启信息窗口
    }
</script>
